package com.lc.cehui.ui.activity;

import android.content.res.ColorStateList;
import android.graphics.Color;
import android.widget.LinearLayout;

import com.google.android.material.tabs.TabLayout;
import com.hjq.bar.TitleBar;
import com.lc.cehui.R;
import com.lc.cehui.app.AppActivity;
import com.lc.cehui.ui.fragment.order.OrderListFragment;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;

public class OrderListActivity extends AppActivity {

    @BindView(R.id.titleBar)
    TitleBar titleBar;
    @BindView(R.id.ll_seach)
    LinearLayout llSeach;
    @BindView(R.id.slidingTabLayout)
    TabLayout slidingTabLayout;
    @BindView(R.id.vp)
    ViewPager viewpager;
    private int comfrom;

    private ArrayList<Fragment> fragments;
    private ArrayList<String> relist;//目录
    private ContentPagerAdapter mAdapter;
    private List<String> ids = new ArrayList<>();
    @Override
    protected boolean isStatusBarEnabled() {
        return true;
    }

    @Override
    public boolean isStatusBarDarkFont() {
        return false;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_order_list;
    }

    @Override
    protected void initView() {
        comfrom = getIntent().getIntExtra("comfrom",0);
        relist = new ArrayList<>();

        fragments = new ArrayList<>();
        fragments.add(OrderListFragment.newInstance(""));
        fragments.add(OrderListFragment.newInstance("0"));
        fragments.add(OrderListFragment.newInstance("1"));
        fragments.add(OrderListFragment.newInstance("2"));
        fragments.add(OrderListFragment.newInstance("3"));
        fragments.add(OrderListFragment.newInstance("4"));
        fragments.add(OrderListFragment.newInstance("6"));

        relist.add("全部");
        relist.add("待付款");
        relist.add("待发货");
        relist.add("待收货");
        relist.add("待评价");
        relist.add("待返还");
        relist.add("退货退款");
        ids.add("0");ids.add("1");ids.add("2");ids.add("3");ids.add("4");ids.add("6");

        mAdapter = new ContentPagerAdapter(getSupportFragmentManager());
     viewpager.setAdapter(mAdapter);

     slidingTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
     slidingTabLayout.setTabRippleColor(ColorStateList.valueOf(Color.parseColor("#00000000")));
   slidingTabLayout.setupWithViewPager(viewpager);
   slidingTabLayout.getTabAt(comfrom+1).select();
    viewpager.setCurrentItem(comfrom+1);//设置卡在页面
    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.ll_seach)
    public void onClick() {
    }
    class ContentPagerAdapter extends FragmentPagerAdapter {

        public ContentPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return relist.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return relist.get(position);
        }
    }
}